import * as constants from '../Constants'
import { get, GET_SECONDINSTANCE_LIST, GET_INSTANCE_BY_ID } from '../../service/api'

export interface GetSecondInstanceList {
  type: constants.GetSecondInstanceList
  payload: Promise<any>
}

export interface GetSecondInstanceList_PENDING {
  type: constants.GetSecondInstanceList_PENDING
  payload: Promise<any>
}

export interface GetSecondInstanceList_FULFILLED {
  type: constants.GetSecondInstanceList_FULFILLED
  payload: any
}

export interface GetSecondInstanceList_PAGE {
  type: constants.GetSecondInstanceList_PAGE
  payload: any
}

export interface RECORD_SecondInstance {
  type: constants.RECORD_SecondInstance
  payload: Promise<any>
}

export interface RECORD_SecondInstance_FULFILLED {
  type: constants.RECORD_SecondInstance_FULFILLED
  payload: Promise<any>
}

export type SecondInstanceAction = GetSecondInstanceList | 
  GetSecondInstanceList_FULFILLED | 
  GetSecondInstanceList_PENDING | 
  GetSecondInstanceList_PAGE |
  RECORD_SecondInstance |
  RECORD_SecondInstance_FULFILLED

export function getSecondInstanceList(param: any): GetSecondInstanceList {
  return {
    type: constants.GetSecondInstanceList,
    payload: get(GET_SECONDINSTANCE_LIST, param)
  }
}
export function page(page: any): GetSecondInstanceList_PAGE {
  return {
    type: constants.GetSecondInstanceList_PAGE,
    payload: page
  }
}
export function recordDetail(param: any): RECORD_SecondInstance {
  return {
    type: constants.RECORD_SecondInstance,
    payload: get(GET_INSTANCE_BY_ID, param)
  }
}